<style>
.table th { border:1px solid #aaa;
			background: #e9e9e9;
			color: #666666;
			padding: 4px 8px;
			text-align: left;
			white-space: nowrap;
			height: 32px;
			line-height: 32px;}
.table td {
	border:1px solid #aaa;
	
}

</style>
 
<script language="javascript" type="text/javascript" src="/js/my97datepicker/WdatePicker.js"></script>
<script type="text/javascript" src="/js/object.js"></script>
<script type="text/javascript" src="/js/object_ready.js"></script>
<script type="text/javascript" src="/js/address.js"></script>
<script type="text/javascript" src="/js/park.js"></script>
<script type="text/javascript" src="/js/school.js"></script>


<script>
	$("document").ready(function(){


$( "#case_name_123" ).autocomplete({
            source: function(request, response ) {
                $.ajax({
                    //url: "/client/client_josn",
                    ///js/blog/public/abc
                    url: "/js/blog/public/object/caseName",
                    dataType: "json",
                    data:{
                        query: request.term
                    },
                    success: function( data ) {
                        response( $.map( data, function( item ) {
                            return {
                                label: item.case_name,
                                value: item.case_name,
                                recommended: item.recommended
                            }
                        }));
                    }
                });
            },
            select: function(e, ui) {
              $("#recommended").val(ui.item.recommended);
            },
            minLength: 1
    });	


$( "#building_name_123" ).autocomplete({
            source: function(request, response ) {
                $.ajax({
                    //url: "/client/client_josn",
                    ///js/blog/public/abc
                    url: "/js/blog/public/object/buildingName",
                    dataType: "json",
                    data:{
                        query: request.term
                    },
                    success: function( data ) {
                        response( $.map( data, function( item ) {
                            return {
                                label: item.building_name,
                                value: item.building_name,
                                recommended: item.recommended
                            }
                        }));
                    }
                });
            },
            select: function(e, ui) {
              $("#recommended").val(ui.item.recommended);
            },
            minLength: 1
    });	
// 		$( "#case_name_123" ).autocomplete({
//             source: function(request, response ) {
//                 $.ajax({
//                     url: "/object/market_josn",
//                     dataType: "json",
//                     data:{
// 						query: request.term
//                     },
//                     success: function( data ) {
//                         response( $.map( data, function( item ) {
// 	                        return {
// 								label: item.case_name,
// 								value: item.case_name,
// 								recommended: item.building_name
// 	                        }
//                         }));
//                     }
//                 });
//             },
// 			select: function(e, ui) {
// 			  $("#recommended").val(ui.item.case_name);
// 			},
//             minLength: 1
//  	});






		 // $( "#case_name_123" )
   //    //.bind( 'focus', function(){ 
   //    //	$(this).autocomplete("search"); 
   //    //} )
   //    .bind( 'click', function(){ 
   //    	$(this).autocomplete("search"); 
   //    } )
   //    .autocomplete({
   //      minLength: 0,
   //      source: function(request, response ) {
   //              $.ajax({
   //                  url: "/object/case_name_josn",
   //                  dataType: "json",
   //                  data:{
			// 			query: request.term
   //                  },
   //                  success: function( data ) {
   //                      response( $.map( data, function( item ) {
   //                      return {
			// 			label: item.value,
			// 			value: item.value
   //                      }
   //                      }));
   //                  }
   //              });
	  //   },
   //      focus: function() {
   //        return false;
   //      }
   //    });


      //市調狀態
	$( "#object_usage_123123" )
	  .bind( 'focus', function(){ 
		
	  	$(this).autocomplete("search"); 

	  }).bind( 'click', function(){ 

	  	$(this).autocomplete("search"); 
	  	
	  } )
	  .autocomplete({
		minLength: 0,
		source: function(request, response ) {
			//alert(request.term);
	                $.ajax({
	                    url: "/object_usage/object_usage_josn",
	                    dataType: "json",
	                    data:{
						query: request.term
	                    },
	                    success: function( data ) {

	                        response( $.map( data, function( item ) {
	                        return {
								label: item.value,
								value: item.value
	                        }
	                        }));
	                    }
	                });
	    },
		focus: function() {
		  return false;
		},
		select: function( event, ui ) {
			 var terms=new Array();
			 if(this.value!="")
			   terms = this.value.split("/ ");
			 terms.pop();
			 terms.push( ui.item.value );
			 terms.push( "" );
			 this.value = terms.join( "/ " );
			 return false;
		}
	  });	
	});
</script>

 <link href="/css/bootstrap/dist/css/bootstrap.css" type="text/css" rel="stylesheet">

		<form  	method="post" id="userinfo" >

		

				<table class="table" 
				<?=empty($_POST)?'style="display:none;"':''?>
				>
					<tbody>
					<tr>
						<th>顧客</th>
						<td>
							<input type="text"  name="owner" id="owner" 
							value="<?=!empty($_POST["owner"])?$_POST["owner"]:""?>">

						</td>

						<th>售租案</th>
						<td>
							
							<input type="checkbox" value="1" id="type_rent" name="type_rent" 
							<?=!empty($_POST["type_rent"])?($_POST["type_rent"]==1?' CHECKED ':'' ):"";?> 
							>租賃
							<input type="checkbox" value="1" id="type_sale" name="type_sale" <?=!empty($_POST["type_sale"])?($_POST["type_sale"]==1?' CHECKED ':'' ):"";?> >買賣
							<!--
							<input type="checkbox" value="3" id="type_help_seal" name="type_help_seal">租售案
							-->
						</td>
					</tr>

					<tr>
						<th>建物門牌</th>
						<td>
						行政區&nbsp;
							<input type="text"
							id="administrative_area123123"
							value="<?=!empty($_POST["administrative_area"])? $_POST["administrative_area"]:""?>"
							name="administrative_area"
							onclick="show_administrative_area('administrative_area123123');" style="width:80px;">&nbsp;

							<input type="text"
							style="width:60%;"
							id="house_building123"
							value="<?=!empty($_POST["house_building"])? $_POST["house_building"]:""?>"
							name="house_building"
							onclick="show_hous_ebuilding('house_building123');">

						</td>
						<th>區域</th>
						<td>
						<input type="text"  name="area" id="area1" 
						value="<?=!empty($_POST["area"])? $_POST["area"]:""?>"
						onclick="show_emphasis_area('area1')">
						</td>
					</tr>


					<tr>
						<th>物件案名</th>
						<td>
							<input 	id="case_name_123" 
							value="<?=!empty($_POST["case_name"])? $_POST["case_name"]:""?>"
									name="case_name" size="50" style="width:148px;"  />
						</td>
						<th>大樓名稱</th>
						<td>

							
							<input type="text" class="full_select" 
							value="<?=!empty($_POST["building_name"])? $_POST["building_name"]:""?>"
							style="width:200px;" name="building_name" id="building_name_123">

							
						</td>
					</tr>
					<tr>
						<th>物件用途</th>
						<td>
							<input type="text" 
							value="<?=!empty($_POST["object_usage"])? $_POST["object_usage"]:""?>"
							 name="object_usage" id="object_usage_123123">

							
						</td>
						<th>物件狀態</th>
						<td>
							<select class="full_select" style="width:200px;" name="object_state" id="object_state">
							<option value="">&nbsp;</option>
                      		 <?
							foreach($object_state as $key=>$val){
							?>
							<option value="<?=$val->object_state_id?>"
								<?=!empty($_POST["object_state"])?($_POST["object_state"]==$val->object_state_id ?' selected ':'' ):""; ?>
								><?=$val->value?></option>
							<?
							}
							?>
                      		</select>
						</td>
					</tr>
				  <tr>
				    <th>建物面積</th>
				    <td><input type="text" 
				    	value="<?=!empty($_POST["building_area1"])? $_POST["building_area1"]:""?>"
				    	name="building_area1" id="building_area1"> ~ 

				    	<input type="text" name="building_area2" 
				    	value="<?=!empty($_POST["building_area2"])? $_POST["building_area2"]:""?>"
				    	id="building_area2">坪</td>
				    <th>土地面積</th>
				    <td><input type="text" name="base_area1" 
				    	value="<?=!empty($_POST["base_area1"])? $_POST["base_area1"]:""?>"
				    	id="base_area1">~<input type="text" name="base_area2" id="base_area2">坪</td>
				  </tr>
				  <tr>
				    <th>總價</th>
				    <td><input type="text"
				    	value="<?=!empty($_POST["total1"])? $_POST["total1"]:""?>"
				     name="total1" id="total1"> 
				     ~ 
				     <input type="text" 
				     value="<?=!empty($_POST["total2"])? $_POST["total2"]:""?>"
				     name="total2" id="total2">萬</td>
				    <th>範圍<br>
				    	<input type="button" value="設定" 
				    	
				    	onclick="show_range_map();" class="input_background">
				    </th>
				    <td>緯度 <input type="text" 
				    	value="<?=!empty($_POST["latitude1"])? $_POST["latitude1"]:""?>"
				    	name="latitude1" id="latitude1"> ~ 
				    	<input type="text" 
				    	value="<?=!empty($_POST["latitude2"])? $_POST["latitude2"]:""?>"
				    	name="latitude2" id="latitude2"><br>


				        經度 <input type="text" name="longitude1" id="longitude"
				        	value="<?=!empty($_POST["longitude1"])? $_POST["longitude1"]:""?>"
				        	> ~ 
				        	<input type="text" name="longitude2" id="longitude2"
				        	value="<?=!empty($_POST["longitude2"])? $_POST["longitude2"]:""?>"
				        	>
				    </td>
				  </tr>
				  <tr>
				    <th>物件案別</th>
				    <td>

				    	<input type="checkbox" 
				    	 <?=!empty($_POST["type_rent"])?($_POST["type_rent"]==1?' CHECKED ':'' ):"";?> 
				    	value="1" name="object_case_type[]">中古屋 &nbsp;&nbsp;
				    	<input type="checkbox" value="2" name="object_case_type[]">預售 &nbsp;&nbsp;
				    	<input type="checkbox" value="3" name="object_case_type[]">標售
				    </td>
				    <th>屋齡</th>
				    <td><input type="text" 
				    	value="<?=!empty($_POST["year_of_construction1"])? $_POST["year_of_construction1"]:""?>"
				    	name="year_of_construction1" id="year_of_construction1">年~<input type="text" name="year_of_construction2" id="year_of_construction2">年</td>
				  </tr>
				  <tr>
				    <th>經紀人</th>
				    <td colspan="3">

				    	<select name="broker" id="broker">
				    		<option></option>
				    	<?php
				    	foreach($borkers as $broker):
							echo '<option value="'.$broker->users_id.'" ';

							echo !empty($_POST["broker"])?($_POST["broker"]==$broker->users_id ?' selected ':'' ):"";

							echo ' >'.$broker->name.'</option>';
						endforeach;
				    	?>
				    	</select>
				    </td>
				  </tr>

				  <tr style="display:none;">
				    <th>委託起日</th>
				    <td><input type="text" 
				    	value="<?=!empty($_POST["entrust_start1"])? $_POST["entrust_start1"]:""?>"
				    	class="Wdate" style="width:100px;"  onclick="WdatePicker()" name="entrust_start1" id="entrust_start1"> ~ <input type="text" class="Wdate" onclick="WdatePicker()" style="width:100px;" name="entrust_start2" id="entrust_start2"></td>
				    <th>委託迄日</th>
				    <td><input type="text" 
				    	value="<?=!empty($_POST["entrust_end1"])? $_POST["entrust_end1"]:""?>"
				    	class="Wdate" onclick="WdatePicker()" style="width:100px;" name="entrust_end1"  id="entrust_end1"> ~ <input type="text" class="Wdate" onclick="WdatePicker()" style="width:100px;" name="entrust_end2" id="entrust_end2"></td>
				  </tr>

				  <tr>
				    <th>排序</th>
				    <td>
				    	<select class="full_select" style="width:100px;" name="orderby" id="orderby">
				    		<option value="ctime">建檔日期</option>
				    	</select>
				    	&nbsp;
				    	<select class="full_select" style="width:100px;" name="sort"  id="sort">
				    		<option value="desc"
				    		<?=!empty($_POST["sort"])?($_POST["sort"]=="desc"?' SELECTED ':'' ):"";?> 
				    		>降冪排列</option>
				    		<option value="asc"
				    		<?=!empty($_POST["sort"])?($_POST["sort"]=="asc"?' SELECTED ':'' ):"";?> 
				    		>升冪排列</option>
				    	</select>
				    </td>
				    <th>密件</th>
				    <td>
							<input type="radio" value="N" name="bcc" id="bcc"
								<?=!empty($_POST["bcc"])?($_POST["bcc"]=="N"?' CHECKED ':'' ):"";?> 
							>否
							<input type="radio" value="Y" name="bcc" id="bcc"
								<?=!empty($_POST["bcc"])?($_POST["bcc"]=="Y"?' CHECKED ':'' ):"";?> 
							>是
						</td>
				  </tr>
				  <tr>
				    <th>物件編號</th>
				    <td><input type="text"  name="object_no" 
				    	value="<?=!empty($_POST["object_no"])? $_POST["object_no"]:""?>"
				    	id="object_no"></td>
				    <th>所在樓層</th>
				    <td><input type="text"  
				    	value="<?=!empty($_POST["floor1"])? $_POST["floor1"]:""?>"
				    	name="floor1" id="floor1"> ~
				    	<input type="text"  name="floor2" id="floor2"
				    	value="<?=!empty($_POST["floor2"])? $_POST["floor2"]:""?>"
				    	>
				    </td>
				  </tr>

				  <tr>
				    <th>關鍵字</th>
				    <td><input type="text" 
				    	value="<?=!empty($_POST["keywords"])? $_POST["keywords"]:""?>"
				    	name="keywords" id="keywords"></td>
				    <th>建檔日期</th>
				    <td><input type="text" 
				    	value="<?=!empty($_POST["sctime"])? $_POST["sctime"]:""?>"
				    	class="Wdate" style="width:100px;" onclick="WdatePicker()" name="sctime" id="sctime"> ~ 
				    	<input type="text" 
				    	value="<?=!empty($_POST["ectime"])? $_POST["ectime"]:""?>"
				    	class="Wdate" style="width:100px;" onclick="WdatePicker()" name="ectime" id="ectime"></td>
				  </tr>

				  <tr>
				  	<td>&nbsp;</td>
				  	<td colspan="3">
					  <input type="submit" value="查詢確認" class="input_background">
				  	</td>
			     </tr>

				</tbody>
			</table>
	</form>
	


